﻿using System;
using System.Configuration;
using System.ComponentModel;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Csla.Validation;

//using SubSonic.Repository;
//using SubSonic.SqlGeneration.Schema;
namespace GanagroLiteBO
 {
    public partial class Operacion_BO : IEditableObject, INotifyPropertyChanged, IDataErrorInfo 
{

    #region Constructors
    #endregion
    #region Private Fields
        private bool m_Editing; 
        protected short? _OPERACION;	
	    protected DateTime _FECHA;	
	    protected float? _VALOR1;	
	    protected float? _VALOR2;	
	    protected short? _NCOMENTARIO;	
	    protected short? _IDEMPLEADO;	
	    protected string _COMENTARIO;	
	    private int _ID;	
	    private bool _Isdirty = false;
    #endregion
    #region Public Properties
    public bool Isdirty  { get { return _Isdirty; } set {_Isdirty = value;} }

	public short? OPERACION
	    {
		    get { return _OPERACION; }
		    set { 

		        if (_OPERACION != value) 
		        { _OPERACION = value;
		         FirePropertyChangedNotification("OPERACION");
		        }
		    }
	    }

	public DateTime FECHA
	    {
		    get { return (_FECHA == DateTime.MinValue ?  Convert.ToDateTime("1900-01-01") : _FECHA) ; }
		    set { 
		    if (_FECHA != value) 
		    { _FECHA = value.Date;
		     FirePropertyChangedNotification("FECHA");
		    }
		    }
	    }

	public float? VALOR1
	    {
		    get { return _VALOR1; }
		    set { 
		    if (_VALOR1 != value) 
		    { _VALOR1 = value;
		     FirePropertyChangedNotification("VALOR1");
		    }
		    }
	    }

	public float? VALOR2
	    {
		    get { return _VALOR2; }
		    set { 
		    if (_VALOR2 != value) 
		    { _VALOR2 = value;
		     FirePropertyChangedNotification("VALOR2");
		    }
		    }
	    }
	
    public short? NCOMENTARIO
	    {
		    get { return _NCOMENTARIO; }
		    set { 
		    if (_NCOMENTARIO != value) 
		    { _NCOMENTARIO = value;
		     FirePropertyChangedNotification("NCOMENTARIO");
		    }
		    }
	    }
	
     public short? IDEMPLEADO
	    {
		    get { return _IDEMPLEADO; }
		    set { 
		    if (_IDEMPLEADO != value) 
		    { _IDEMPLEADO = value;
		     FirePropertyChangedNotification("IDEMPLEADO");
		    }
		    }
	    }

	    public string COMENTARIO
	    {
		    get { return _COMENTARIO; }
		    set { 
		    if (_COMENTARIO != value) 
		    { _COMENTARIO = value;
		     FirePropertyChangedNotification("COMENTARIO");
		    }
		    }
	    }

	    public int ID
	    {
		    get { return _ID; }
		    set { 
		    if (_ID != value) 
		    { _ID = value;
		     FirePropertyChangedNotification("ID");
	    }
	    }
	    }
    #endregion

    #region INotifyPropertyChanged Implementation
		protected void FirePropertyChangedNotification(string propName)
		{
			if (PropertyChanged != null)
			{
				PropertyChanged(this,new PropertyChangedEventArgs(propName));
			}
            ValidationRules.CheckRules(propName);
		}

		public event PropertyChangedEventHandler PropertyChanged;
    #endregion

    #region IDataErrorInfo Members

//				    private string m_Error = string.Empty;
//				    private Hashtable m_PropErrors = new Hashtable();

				    [Browsable(false)]
				    public string Error
				    {
                        get
                        {
                            if (!ValidationRules.IsValid)
                            { return ValidationRules.GetBrokenRules().ToString(Csla.Validation.RuleSeverity.Error); }
                            else
                            { return String.Empty; }
                        }
                    }

                    [Browsable(false)]
                    public string this[string columnName]
                    {
                        get
                        {
                            string result = string.Empty;
                            if (!ValidationRules.IsValid)
                            {
                                BrokenRule rule = ValidationRules.GetBrokenRules().GetFirstBrokenRule(columnName);
                                if (rule != null)
                                    result = rule.Description;
                            }
                            return result;
                        }
                    }
				    #endregion

	#region IEditableObject Members

				public void BeginEdit()
				{
                    //if (!m_Editing)
                    //{
                    //}

					m_Editing = true;
				}

				public void CancelEdit()
				{
					m_Editing = false;
				}

				public void EndEdit()
				{
                    //if (m_Editing)
                    //{
                    //}

					m_Editing = false;
				}

				#endregion
}

 }

